package com.message.api.user.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.message.api.user.entity.AcLoginlog;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author mzl
 * @since 2021-05-20
 */
public interface AcLoginlogService extends IService<AcLoginlog> {

    /**
     * 条件查询
     *
     * @param example
     * @return
     */
    List<AcLoginlog> list(AcLoginlog example);

    /**
     * 分页查询
     *
     * @param example
     * @param page
     * @return
     */
    IPage<AcLoginlog> page(AcLoginlog example, IPage page);

    /**
     * 账号在半个小时内的记录
     *
     * @param username
     * @param successTime
     * @return
     */
    List<AcLoginlog> findByUsernameLastErrorlog(String username, Date successTime);

    /**
     * 获取最近成功的记录
     *
     * @param username
     * @return
     */
    AcLoginlog findByLastSuccessLog(String username);

    /**
     * 是否允许登录
     *
     * @param username
     * @return
     */
    Boolean toLogin(String username);

    /**
     * 添加日志
     *
     * @param userid
     * @param username
     * @param result
     * @param remark
     * @return
     */
    @Transactional
    AcLoginlog addLog(Integer userid, String username, String result, String remark);

}
